{% extends 'base.html' %}
{% load static %}
{% block title %}新闻动态{% endblock %}
<!--图片-->
{% block navImg %}
    <img style="width: 100%" src="{% static 'images/new.jpg' %}" alt="新闻动态"/>
{% endblock %}

<!--主体内容-->
{% block content %}
    <div id="new">
        <div class="row">
            <div class="col-md-3 mode-menu">
                <div class="mode-menu-title">新闻动态</div>
                <div class="mode-item"><a href="{% url 'new' 1 %}">企业要闻</a></div>
                <div class="mode-item"><a href="{% url 'new' 2 %}">行业新闻</a></div>
                <div class="mode-item"><a href="{% url 'new' 3 %}">通知公告</a></div>
            </div>
            <div class="col-md-9">

                <div class="row">

                    <div class="mode-title">
                        {{ title }}
                        <!--全文检索搜索框-->
                        <div class="search">
                            <form method="get" action="{% url 'haystack_search' %}">
                                {% csrf_token %}
                                <div class="input-group">
                                    <input type="text" name="q" class="form-control" placeholder="请输入关键词" required/>
                                    <span class="input-group-btn">
                                        <input type="submit" class="btn btn-default" value="查询"/>
                                    </span>
                                </div>
                            </form>
                        </div>
                    </div>

                    {% for item in data %}
                        <div class="new-item">
                            <div class="new-title row">
                                <div class="col-md-10">
                                    <img src="{% static 'images/newsicon.gif' %}" alt="icon"/>
                                    <a href="{% url 'new_detail' item.id %}">{{ item.title }}</a>
                                </div>
                                <div class="col-md-2">【{{ item.pubDate | date:"Y-m-d" }}】</div>
                            </div>
                            <div class="new-content padding2">{{ item.content|striptags|truncatechars:"100" }}</div>
                        </div>
                    {% endfor %}

                    <!--分页-->
                    {% if data.paginator.num_pages > 1 %}
                        <div class="new-page">
                            <ul class="pagination">
                                {% for item in data.paginator.page_range %}
                                    {% if data.number == item %}
                                        <li class="active"><a href="#">{{ item }}</a></li>
                                    {% else %}
                                        <li><a href="?num={{ item }}">{{ item }}</a></li>
                                    {% endif %}
                                {% endfor %}
                            </ul>
                        </div>
                    {% endif %}
                </div>
            </div>
        </div>
    </div>
{% endblock %}